{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>用户列表</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->
            <div class="row">
                <div class="col-sm-12">
                    <form name="admin_list_sea" class="form-search" method="get" action="{:url('charge')}">
                        <div class="col-sm-3">
                            <div class="input-group">
                                <select class="form-control m-b chosen-select" name="status" id='status'>
                                    <option value="0">选择充值状态</option>
                                    <option value="1" {eq name="data.status" value="1"}selected{/eq}>待审核</option>
                                    <option value="2" {eq name="data.status" value="2"}selected{/eq}>已通过</option>
                                    <option value="3" {eq name="data.status" value="3"}selected{/eq}>被拒绝</option>
                                </select>

                                <span class="input-group-btn">
                                    <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                                </span>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th>ID</th>
                                <th>昵称</th>
                                <th>电话</th>
                                <th>真实姓名</th>
                                <th>充值金额</th>
                                <th>打款截图</th>
                                <th>状态</th>
                                <th>打款时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="list-content">
                        {volist name="data.charges" id="vo"}
                              <tr class="long-td">
                                  <td>{$vo.id}</td>
                                  <td>{$vo.seller.name}</td>
                                  <td>{$vo.seller.mobile}</td>
                                  <td>{$vo.seller.username}</td>
                                  <td>{$vo.account}</td>
                                  <td><img src="{$vo.picture}"></td>
                                  <td>
                                  {switch name="vo.status"}
                                      {case value="1"}待审核{/case}
                                      {case value="2"}已通过{/case}
                                      {default /}被拒绝
                                  {/switch}
                                  </td>
                                  <td>{$vo.add_time|date="Y-m-d H:i:s",###}</td>
                                  <td>
                                      <a href="javascript:;" onclick="lookPicture(this,{$vo.id});" class="btn btn-primary btn-xs"><i class="fa fa-paste"></i> 查看打款截图</a>&nbsp;&nbsp;
                                  {eq name="vo.status" value="1"}
                                      <a href="javascript:;" onclick="chargeExamine(this,{$vo.id});" class="btn btn-primary btn-xs"><i class="fa fa-paste"></i> 审核</a>&nbsp;&nbsp;
                                  {/eq}
                                  </td>
                              </tr>
                        {/volist}
                        </tbody>
                    </table>

                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

{include file="public/footer" /}
<script type="text/javascript">
    function lookPicture(obj,id) {
        $.post('/admin/Seller/picture/id/'+id,{'id':id},function(json){
            // console.log(json);
            layer.photos({
                photos: json
                ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
            });
        },'json');
    }

    function chargeExamine(obj,id) {
      var index = layer.confirm('请审核该商户的打款', {
          btn: ['同意','拒绝'] //按钮
      }, function(){
          $.post('{:url("chargeExamine")}',{'id':id,'status':2},function(data){
              // console.log(data);
              if(data.code == 1){
                  layer.msg(data.msg,{icon:1,time:1500,shade: 0.1}, function(){
                      window.location.href = '{:url("charge")}';
                  });
              }else{
                  layer.msg(data.msg,{icon:2,time:1500,shade: 0.1}, function(){
                      layer.close(index);
                  });
              }
          },'json')
      }, function(){
          chargeRefuse(id);
      });
    }

    function chargeRefuse(id) {
        layer.prompt({
            title: '请输入审核不通过的原因'
            , formType: 2
            , area: ['500px', '300px'] //自定义文本域宽高
        }, function(text, index){
            $.post('{:url("chargeExamine")}',{'id':id,'status':3,'content':text},function(data){
                if(data.code == 1){
                    layer.msg(data.msg,{icon:1,time:1500,shade: 0.1}, function(){
                        window.location.href = '{:url("charge")}';
                    });
                }else{
                    layer.msg(data.msg,{icon:2,time:1500,shade: 0.1}, function(){
                        layer.close(index);
                    });
                }
            },'json')
        });
    }
</script>
</body>
</html>
